home *** CD-ROM | disk | FTP | other *** search
/ ETO Development Tools 1 / ETO Development Tools 1.iso / Essentials / MacApp Documentation / MacApp AppleLink Messages / MacApp.Tech$ 3⁄23⁄90 / 0938-MA FileFiltering-Mar90 < prev    next >
Encoding:
Text File  |  1990-03-23  |  3.9 KB  |  102 lines  |  [TEXT/GEOL]

  1. Item    9444121                         20-March-90        09:18PST
  2.  
  3. From:   CDA0470                         DEV PhySy Music & Development,IDV
  4.  
  5. To:     MACAPP.TECH$                    MacApp Technical
  6.  
  7. Sub:    MA FileFiltering
  8.  
  9. Hello all!
  10.  
  11. Enclosed is some code that I am working on. What I am having problems with is
  12. toggling between different file types in an SFOpen Dialog.  I have no problems
  13. with the setting of the buttons or the initial setting of the FileFilter, its
  14. just updating the FileFilter that is causing some problems. This is code that I
  15. am bringing over from a non-MA program, where it worked fine. Even now I can
  16. hear the disk turning, like it is creating a new file list, it's just that
  17. nothing shows up. I can't quite figure it out. Any help would be appreciated.
  18.  
  19. Phil Smy
  20. PMD
  21. CDA0470
  22.  
  23. {*******************}
  24. procedure TESQ1Application.SFGetParms (itscmdNumber: CmdNumber; var dlgID:
  25. integer; var where: Point; var fileFilter, dlgHook, filterProc: ProcPtr;
  26. typeList: HTypeList);
  27.   OVERRIDE;
  28. begin
  29.   inherited SFGetParms(itscmdNumber, dlgID, where, fileFilter, dlgHook,
  30. filterProc, typeList); {}
  31. {let MacApp set default values }
  32.   if (itscmdNumber = cNew) or (itscmdNumber = cOpen) then
  33.    begin
  34.     SetHandleSize(Handle(typeList), 4);           { allow only ‘Bank’ files }
  35.     typeList^^[1] := 'Bank';
  36.     gWhichOne := kESQORgPlus;
  37.     dlgID := kOpenDialogID;          { use custom dialog resource }
  38.     dlgHook := @MySFHook;     { splice in our own dlgHook to handle custom}
  39.                                                    {dialog controls }
  40.     fileFilter := @SFFileFilter;                    { do extra file filtering }
  41.    end
  42.  end;
  43.  
  44.  function SFFileFilter (p: parmBlkPtr): boolean;
  45.  begin                                               {SFFileFilter}
  46.   SFFileFilter := TRUE;                         {Don't show it -- default}
  47.   case gWhichOne of
  48.    kESQOrgOld:                                     {My Old}
  49.     if p^.ioFlFndrInfo.fdType = 'ESQ1' then
  50.      SFFileFilter := FALSE; {Show it}
  51.    kSoundFile:                        {Blank/Beaverton (saved as Bank only)}
  52.     if p^.ioFlFndrInfo.fdType = 'EBNK' then
  53.      SFFileFilter := FALSE;
  54.    kESQORgPlus:                                    {My New}
  55.     if p^.ioFlFndrInfo.fdType = 'Bank' then
  56.      SFFileFilter := FALSE; {Show it}
  57.    otherwise
  58.     ;
  59.   end;
  60.  end;                                                {SFFileFilter}
  61.  
  62.  function MySFHook (MySFitem: integer; theDialog: DialogPtr): integer;
  63.   const
  64.    ESQOrgOldButton = 11;
  65.    SoundFileButton = 12;
  66.    ESQOrgPlusbutton = 13;
  67.    firstTime = -1;           {the first time our hook is called, it is}
  68. {                                                         passed a -1}
  69.  
  70.    reDrawList = 101;          {returning 101 as item number will cause the}
  71. {                                    file list to be recalculated}
  72.    btnOn = 1;                        {control value for on}
  73.    btnOff = 0;                        {control value for off}
  74.  
  75.   var
  76.    itemToChange: Handle;           {needed for GetDItem and SetCtlValue}
  77.    itemBox: Rect;                       {needed for GetDItem}
  78.    itemType: integer;                    {needed for GetDItem}
  79.    buttonTitle: Str255;                     {needed for GetIndString}
  80.  
  81.  begin                                               {MySFHook}
  82.   case MySFitem of
  83.  
  84.    firstTime:
  85.     begin                 { before the dialog is drawn, our hook gets called }
  86.             { with a -1 (firstTime) as the item so we can change }
  87.             {  things like button titles, etc. }
  88.  {Set buttons to correct state}
  89.     MySFHook := MySFitem;             {pass back the same item we were sent}
  90.     end;                                        {firstTime}
  91.    ESQOrgOldButton:
  92.     begin
  93.      if gWhichOne <> 1 then
  94.       begin
  95.         {Set buttons}
  96.        gWhichOne := kESQOrgOld;
  97.        MySFHook := reDrawList;       {we must tell SF to redraw the list}
  98.       end;
  99.     end;                                    {ESQOrgOldButton}
  100.  
  101.  
  102.